<template>
	<view class="homework">
		<view class="name">{{getHomeworkInfo.name}}</view>
		<view class="time">截止时间：{{getHomeworkInfo.endTime}}</view>
		<view class="total">试题数量：{{getHomeworkInfo.subjectSize}}</view>
		<view class="btn" @click="access">开始测评</view>
	</view>
</template>

<script>
	import {showToast} from '@/utils/index.js'
	import {mapGetters, mapActions} from 'vuex'
	export default {
		data() {
			return {
				lessonId: ''
			}
		},
		computed:{
			...mapGetters('homeworkStore',[
				'getHomeworkInfo'
			])
		},
		onLoad(query) {
			this.lessonId = query.lessonId;
			this.loadHomeworkSubjects(this.lessonId);
		},
		methods:{
			...mapActions('homeworkStore',[
				'loadHomeworkSubjects'
			]),
			access(){
				if(this.getHomeworkInfo.subjectSize<=0){
					showToast('没有题目哦');
					return;
				}
				uni.redirectTo({
					url:'/pages/homework/access'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.homework {
		font-size: 34upx;
		color: #333;
		text-align: center;
		padding: 280upx 20upx 0;
		line-height: 1;
	}

	.name {
		font-size: 42upx;
		color: #333333;
		font-weight: 700;
	}

	.total {
		color: #666;
	}
	.time {
		color: #666;
		padding: 68upx 0 40upx;
	}

	.btn {
		position: fixed;
		line-height: 80upx;
		font-size: 38upx;
		color: #FFFFFF;
		background-color: #5ea1f8;
		border-radius: 8upx;
		bottom: 160upx;
		left: 50%;
		right: 70upx;
		width: 532upx;
		height: 79upx;
		margin-left: -266upx;
	}
</style>
